<template>
  <div class="app-container">

    <el-form :model="currentSetting" ref="currentSetting" label-width="500px" class="demo-ruleForm">
  <el-form-item
    label="待付款订单取消时间：拍下订单 "
    prop="age"
    :rules="[
      { required: false, message: '时间不能为空'},
      { type: 'number', message: '时间必须为数字值'}
    ]"
  >
    <el-input style="width:100px" type="age" v-model="currentSetting.orderDeadtime" autocomplete="off"></el-input>分钟内未付款，自动取消订单
  </el-form-item>

    <el-form-item
    label="累计消费满 "
    prop="pay"
    :rules="[
      { required: false, message: '金额不能为空'},
      { type: 'number', message: '金额必须为数字值'}
    ]"
  >
    <el-input style="width:100px" type="pay" v-model="currentSetting.upgrade" autocomplete="off"></el-input>   元,升一级
  </el-form-item>

  <el-form-item
    label="会员最高等级 "
    prop="grade"
    :rules="[
      { required: false, message: '等级不能为空'},
      { type: 'number', message: '等级必须为数字值'}
    ]"
  >
    <el-input style="width:100px" type="grade" v-model="currentSetting.maxgrade" autocomplete="off"></el-input>   级
  </el-form-item>

    <el-form-item
    label="每100积分可抵扣 "
    prop="money"
    :rules="[
      { required: false, message: '金额不能为空'},
      { type: 'number', message: '金额必须为数字值'}
    ]"
  >
    <el-input style="width:100px" type="money" v-model="currentSetting.moneyIntegralProportion" autocomplete="off"></el-input>   元
  </el-form-item>

  <el-form-item>
    <el-button type="primary" @click="submitForm('currentSetting')">提交</el-button>
    <el-button @click="resetForm()">重置</el-button>
  </el-form-item>
</el-form>
    </div>
</template>
<script>
//引入调用slideShow.js文件
import mySetting from "@/api/setting";

export default {
  //写核心代码位置
  // data:{
  // },
  data() {
    //定义变量和初始值
    return {
      listLoading: true, // 是否显示loading信息
      list: null, //查询之后接口返回集合
      total: 0, //总记录数
      currentSetting: {
        orderDeadtime: 1,
        upgrade:1,
        maxgrade:1,
        integralIntegralProportion:1,
        moneyIntegralProportion:1
      }, //条件封装对象
      checkList: [],
    };
  },
  created() {
    //页面渲染之前执行，一般调用methods定义的方法
    //调用
    this.getCurrentSetting();
  },
  mounted() {
    this.listLoading = false;
  },
  methods: {
    //创建具体的方法，调用slideShow.js定义的方法
    //获取轮播图列表的方法,默认是第一页
    getCurrentSetting() {
      mySetting
        .getCurrentSettingShow()
        .then((response) => {
          //请求成功
          //response接口返回的数据   
          this.currentSetting = response.object;
          console.log(this.currentSetting)
        });
    },
    submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
              mySetting
             .submitSettingShow(this.currentSetting)
                .then((response) => {
                      this.$message({
                      type: "success",
                      message: "修改成功!",
                    });
                     console.log(this.currentSetting)
                    });
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm() {
        this.currentSetting.orderDeadtime= 0,
        this.currentSetting.upgrade=0,
        this.currentSetting.maxgrade=0,
        this.currentSetting.integralIntegralProportion=0,
        this.currentSetting.moneyIntegralProportion=0     
      }

  },
};
</script>
<style>
#content {
  width: 80%;
  margin: 0 auto;
}
.el-row .el-col-24 {
  width: 150px;
}
.el-col-24:nth-child(3),
.el-col-24:nth-child(4) {
  float: right;
}
</style>